import { defineStore } from "pinia";
import { ref } from "vue";
import { loginAPI } from "@/apis/login";

export const useUserStore = defineStore('user', () => {
    const userInfo = ref();
    const getUserInfo = async (user) => {
        const res = await loginAPI(user);
        console.log("res",res);
        userInfo.value = res.result;
        userInfo.value = {account:'无名小白',token:'123sfhewoi'};
    }

    const clearUserInfo = () => {
        userInfo.value = {};
    }

    return {
        userInfo,
        getUserInfo,
        clearUserInfo
    }
}, {
    persist: true,
})
